package com.gitee.cashzhang27.test.boot.crypt.mapper.entity;


import static com.gitee.cashzhang27.test.boot.crypt.mapper.entity.enums.DesensitizeType.BANK_CARD;
import static com.gitee.cashzhang27.test.boot.crypt.mapper.entity.enums.DesensitizeType.FULL_NAME;
import static com.gitee.cashzhang27.test.boot.crypt.mapper.entity.enums.DesensitizeType.ID_CARD;
import static com.gitee.cashzhang27.test.boot.crypt.mapper.entity.enums.DesensitizeType.MOBILE_PHONE;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import com.gitee.cashzhang27.test.boot.crypt.mapper.annotation.CreateTime;
import com.gitee.cashzhang27.test.boot.crypt.mapper.annotation.CreateUser;
import com.gitee.cashzhang27.test.boot.crypt.mapper.annotation.DecryptFiled;
import com.gitee.cashzhang27.test.boot.crypt.mapper.annotation.Depart;
import com.gitee.cashzhang27.test.boot.crypt.mapper.annotation.DesensitizeFiled;
import com.gitee.cashzhang27.test.boot.crypt.mapper.annotation.EncryptFiled;
import com.gitee.cashzhang27.test.boot.crypt.mapper.annotation.LogicDelete;
import com.gitee.cashzhang27.test.boot.crypt.mapper.annotation.ModifiedTime;
import com.gitee.cashzhang27.test.boot.crypt.mapper.annotation.ModifiedUser;
import com.gitee.cashzhang27.test.boot.crypt.mapper.annotation.Tenant;
import java.io.Serializable;
import java.time.LocalDateTime;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author Cash Zhang
 * @version v1.0
 * @since 2019/07/09 15:17
 */
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Table(name = "tb_user")
public class User implements Serializable {

  private static final long serialVersionUID = -7491215402569546437L;

  /**
   * 用户ID
   */
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY, generator = "select replace(uuid(), '-', '')")
  private String id;

  /**
   * 昵称
   */
  private String nickName;
  /**
   * 性别
   */
  private String gender;
  /**
   * 姓名
   */
  @DesensitizeFiled(type = FULL_NAME)
  private String fullName;
  /**
   * 身份证号
   */
  @EncryptFiled
  @DecryptFiled
  @DesensitizeFiled(type = ID_CARD)
  private String idCard;
  /**
   * 银行卡号
   */
  @EncryptFiled
  @DecryptFiled
  @DesensitizeFiled(type = BANK_CARD)
  private String bankCard;
  /**
   * 手机号
   */
  @EncryptFiled
  @DecryptFiled
  @DesensitizeFiled(type = MOBILE_PHONE)
  private String mobilePhone;
  /**
   * 部门ID
   */
  @Depart
  private String departId;
  /**
   * 租户ID
   */
  @Tenant
  private String tenantId;
  /**
   * 是否删除
   */
  @LogicDelete
  @Column(name = "is_deleted")
  private Integer deleted;
  /**
   * 创建人
   */
  @CreateUser
  private String userCreate;
  /**
   * 创建时间
   */
  @CreateTime
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  @JsonDeserialize(using = LocalDateTimeDeserializer.class)
  @JsonSerialize(using = LocalDateTimeSerializer.class)
  private LocalDateTime gmtCreate;
  /**
   * 修改人
   */
  @ModifiedUser
  private String userModified;
  /**
   * 修改时间
   */
  @ModifiedTime
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  @JsonDeserialize(using = LocalDateTimeDeserializer.class)
  @JsonSerialize(using = LocalDateTimeSerializer.class)
  private LocalDateTime gmtModified;

}


